package cn.group.service.impl;

import cn.group.mapper.GoodSalesMapper;
import cn.group.service.GoodSalesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.qo.GoodSales;

import java.util.List;

@Service
public class GoodSalesServiceImpl implements GoodSalesService {

    @Autowired
    private GoodSalesMapper goodSalesMapper;

    @Override
    public List<GoodSales> showGoodSales() {
        return goodSalesMapper.selectGoodSales();
    }

    @Override
    public int updatePurchased(GoodSales goodSales) {
            GoodSales hasGoodSales=goodSalesMapper.hasGoodSales(goodSales);
        System.out.println("更新购买量"+hasGoodSales);
            if (null!=hasGoodSales){
                System.out.println("商品销量已存在");
                Long i=hasGoodSales.getSalesPurchased();
                goodSales.setSalesPurchased(goodSales.getSalesPurchased()+i);
                System.out.println("增加的数据量"+goodSales.getSalesPurchased());
            }
        return goodSalesMapper.updateGoodSales(goodSales);
    }
}
